package com.lanxiaoye.shoppingSystem.service.impl;

import com.lanxiaoye.shoppingSystem.dao.GoodsMapper;
import com.lanxiaoye.shoppingSystem.entity.Goods;
import com.lanxiaoye.shoppingSystem.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2017/3/24.
 */
@Service
public class GoodsServiceImpl implements GoodsService{

    @Autowired
    GoodsMapper goodsMapper;

    @Override
    public List<Goods> getTopSalesEight() {
        return goodsMapper.selectTopSalesEight();
    }

    @Override
    public List<Goods> getByCategoryId(int categoryId) {
        return goodsMapper.selectByCategoryId(categoryId);
    }

    @Override
    public Goods getByGoodsId(int goodsId) {
        return goodsMapper.selectByPrimaryKey(goodsId);
    }

    @Override
    public List<Goods> getRelatedGoods(String brand,int goodsId) {
        return goodsMapper.selectRelatedByBrand(brand,goodsId);
    }

    @Override
    public List<Goods> getSearchGoods(String keyword) {
        return goodsMapper.selectByKeyword("%"+keyword+"%");
    }
}
